package com.UdpRecieve.service.impl;

import com.UdpRecieve.domain.SysFileType;
import com.UdpRecieve.mapper.SysConfigMapper;
import com.UdpRecieve.service.SysFileTypeService;
import com.UdpRecieve.tool.Convert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SysFileTypeServiceImpl implements SysFileTypeService {

    @Autowired
    private SysConfigMapper sysConfigMapper;

    @Override
    public List<SysFileType> selectSysFileTypeList() {
        return sysConfigMapper.selectAllFT();
    }

    @Override
    public int deleteSysFileTypeListByIds(String ids) {
        Integer[] userIds = Convert.toIntArray(ids);
        return sysConfigMapper.deleteSysFileTypeListByIds(userIds);
    }

    @Override
    public int initFileType(SysFileType sysFileType) {
        int count = sysConfigMapper.selectFTByValue("."+sysFileType.getTypeValue().trim());
        if (count>0){
            return -2;
        }else {
            sysFileType.setTypeValue("."+sysFileType.getTypeValue().trim());
            return sysConfigMapper.addFileType(sysFileType.getTypeValue());
        }

    }
}
